<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/vendor/bootstrap/css/bootstrap.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Custom Font Icons CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/font.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/custom.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/layer.css">
    <title>我的收藏</title>

</head>
<body>
<header class="header">
    <nav class="navbar navbar-expand-lg">
        <div class="search-panel">
            <div class="search-inner d-flex align-items-center justify-content-center">
                <div class="close-btn">Close <i class="fa fa-close"></i></div>
                <form id="searchForm" action="#">
                    <div class="form-group">
                        <input type="search" name="search" placeholder="What are you searching for...">
                        <button type="submit" class="submit">Search</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="container-fluid d-flex align-items-center justify-content-between">
            <div class="navbar-header">
                <!-- Navbar Header--><a href="${pageContext.request.contextPath}/view/home" class="navbar-brand">
                <div class="brand-text brand-big visible text-uppercase"><strong
                        class="text-primary">小标</strong><strong>交友</strong></div>
                <div class="brand-text brand-sm"><strong class="text-primary">X</strong><strong>B</strong></div>
            </a>
                <!-- Sidebar Toggle Btn-->
                <button class="sidebar-toggle"><i class="fa fa-long-arrow-left"></i></button>
            </div>
            <div class="right-menu list-inline no-margin-bottom">
                <!-- Log out -->
                <div class="list-inline-item logout">
                    <a id="logout" href="${pageContext.request.contextPath}/login/Logout" class="nav-link"><span
                            class="d-none d-sm-inline">Logout </span></a>
                </div>
            </div>
        </div>
    </nav>
</header>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <nav id="sidebar">
        <!-- Sidebar Header-->
        <div class="sidebar-header d-flex align-items-center">
            <div id="avatar" class="avatar">
                <c:if test="${sessionScope.userBaseInfo.pic == null}">
                    <img id="myHeadPic" src="${pageContext.request.contextPath}/assets/img/avatar-6.jpg" alt="..." class="img-fluid rounded-circle">
                </c:if>

                <c:if test="${sessionScope.userBaseInfo.pic != null}">
                    <img id="myHeadPic" src="${pageContext.request.contextPath}${sessionScope.userBaseInfo.pic}" alt="..." class="img-fluid rounded-circle">
                </c:if>
            </div>
            <div class="title">
                <h1 class="h5">${sessionScope.userBaseInfo.username}</h1>
                <p>${sessionScope.userBaseInfo.deptName}</p>
            </div>
        </div>
        <!-- Sidebar Navidation Menus--><span class="heading">Main</span>
        <ul class="list-unstyled">
            <li><a href="${pageContext.request.contextPath}/view/home"> <i class="icon-home"></i>主页 </a></li>
            <li><a href="#userDropdown" data-toggle="collapse" aria-expanded="true"> <i
                    class="icon-windows"></i>用户列表</a>
                <ul id="userDropdown" class="collapse show">
                    <li><a href="${pageContext.request.contextPath}/user/list">查看用户</a></li>
                    <li><a href="${pageContext.request.contextPath}/view/myUser">我关注的用户</a></li>
                    <li><a href="${pageContext.request.contextPath}/view/article">发布文章</a></li>
                    <li class="active"><a href="${pageContext.request.contextPath}/art/favList">我的收藏</a></li>
                </ul>
            </li>
            <!--<li><a href="login.html"> <i class="icon-logout"></i>Login page </a></li>-->

            <li><a href="#depDropdown" data-toggle="collapse"> <i class="icon-windows2"></i>部门列表</a>
                <ul id="depDropdown" class="collapse list-unstyled ">
                    <li><a href="${pageContext.request.contextPath}/view/department">全部部门</a></li>
                    <li><a href="${pageContext.request.contextPath}/meet/list">会议系统</a></li>
                </ul>
            </li>

        </ul>

    </nav>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">我收藏的文章</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

            <div class="list-group myArtList">
                <!--搜索文章的条件-->
                <div class="myTitle">
                    <form class="form-inline">
                        <div class="form-group" action="${pageContext.request.contextPath}/art/favList" method="post">
                            <label for="inlineFormInput" class="sr-only">Name</label>
                            <input id="inlineFormInput" type="text" placeholder="按标题名字查找" class="mr-sm-3 form-control" name="search">
                        </div>
                        <div class="form-group">
                            <input type="submit" value="查询" class="btn btn-primary">
                        </div>
                    </form>

                    <!--<input id = "addArt" type="submit" value="发布文章" class="btn btn-primary">-->

                </div>

                <ul>
                    <c:forEach items="${requestScope.favList}" var="fav">
                        <li class="list-group-item">
                            <div style="float: right;">
                                <span><strong>收藏数：</strong>${fav.follows}</span>
                                <span>&nbsp;</span>
                                <span>&nbsp;</span>
                                <span>&nbsp;</span>
                                <span><strong>浏览数：</strong>${fav.artCount}</span>
                            </div>
                            <a href="${pageContext.request.contextPath}/view/artDetail?det=true&artId=${fav.favAId}">${fav.artTitle}</a>
                            <p class="h6"><strong>作者：</strong>${fav.userName}</p>
                            <p class="h6"><strong>时间：</strong><fmt:formatDate value="${fav.artDate}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></p>
                            <p style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis">${fav.artCont}</p>
                        </li>
                    </c:forEach>
                </ul>

                <nav class="text-center" aria-label="Page navigation">
                    <ul id="pageUL" class="pagination">
                        <li>
                            <a id="pre" href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <c:forEach var="index" varStatus="status" begin="${requestScope.startPage}"
                                   end="${requestScope.endPage}" step="1">
                            <c:if test="${status.count + (requestScope.startPage - 1) == requestScope.currentPage}">
                                <c:if test="${requestScope.search == null}">
                                    <li data-page="${index}"><a class="active" href="${pageContext.request.contextPath}/view/artCollect?page=${index}">${index}</a></li>
                                </c:if>

                                <c:if test="${requestScope.search != null}">
                                    <li data-page="${index}"><a class="active" href="${pageContext.request.contextPath}/view/artCollect?page=${index}&search=${requestScope.search}">${index}</a></li>
                                </c:if>
                            </c:if>

                            <c:if test="${status.count + (requestScope.startPage - 1) != requestScope.currentPage}">
                                <c:if test="${requestScope.search == null}">
                                    <li data-page="${index}"><a href="${pageContext.request.contextPath}/view/artCollect?page=${index}">${index}</a></li>
                                </c:if>

                                <c:if test="${requestScope.search != null}">
                                    <li data-page="${index}"><a href="${pageContext.request.contextPath}/view/artCollect?page=${index}&search=${requestScope.search}">${index}</a></li>
                                </c:if>
                            </c:if>
                        </c:forEach>
                        <li>
                            <a id="next" href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>

        <footer class="footer">
            <div class="footer__block block no-margin-bottom">
                <div class="container-fluid text-center">
                    <p class="no-margin-bottom">Copyright &copy; 2019.Company <a href="#">东方标准</a></p>
                </div>
            </div>
        </footer>
    </div>
</div>

<!-- JavaScript files-->
<script src="${pageContext.request.contextPath}/assets/vendor/jquery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/popper.js/umd/popper.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/jquery.cookie/jquery.cookie.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/chart.js/Chart.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/layer.js"></script>
<script src="${pageContext.request.contextPath}/assets/vendor/jquery-validation/jquery.validate.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/charts-home.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/front.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/custom.js"></script>
<script>
    $(function () {
        $("#pre").click(function () {
            var li = $("#pageUL>li:nth-child(2)");
            var firstPage = li.attr("data-page");
            if ('1' === firstPage) {
                layer.msg("前面没有页码了");
                return;
            }
            window.location.href = '${pageContext.request.contextPath}/view/artCollect?page=' + (Number(firstPage) - 1);
        });

        $("#next").click(function () {
            var li = $("#pageUL>li:nth-child(2)");
            var firstPage = li.attr("data-page");
            var maxPage = Number(firstPage) + 4;
            var totalPage = '' + ${requestScope.totalPage};
            if (Number(totalPage) <= maxPage) {
                layer.msg("后面没有页码了");
                return;
            }
            window.location.href = '${pageContext.request.contextPath}/view/artCollect?page=' + (Number(firstPage) + 5);
        })
    })
</script>
</body>
</html>